import { createRouter, createWebHashHistory } from 'vue-router';
import routes from './routes';
import { toPage, isWeiXin, reLaunch } from '@/utlis/tools';

const router = createRouter({
    history: createWebHashHistory(),
    routes,
    scrollBehavior: (to, from, savePosition) => {
        if (savePosition) {
            return savePosition;
        } else {
            return { x: 0, y: 0 };
        }
    },
});
router.beforeEach((to, from, next) => {
    document.title = (to.meta && to.meta.title) || '';
    next()
    // if (to.meta?.isLogin) { //需要登录
    //     let token = window.localStorage.getItem("token");
    //     if (token) {
    //         next();
    //     } else {
    //         next("/me?istoken=1");
    //     }
    // } else {
    //     next();
    // }
});
export default router;